package com.cms.bs.app.controller;

import com.cms.bs.app.model.Article;
import com.cms.bs.app.service.IArticleService;
import com.cms.bs.config.rs.PageRS;
import com.cms.bs.config.rs.RS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by jiang on 2016-09-28.
 */
@Controller
@RequestMapping(value = "/article")
public class ArticleController {

    @Autowired
    private IArticleService articleService;

    @RequestMapping(method = RequestMethod.POST)
    @ResponseBody
    public RS create(@RequestBody Article article) {
        return articleService.create(article);
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
    @ResponseBody
    public RS delete(@PathVariable String id) {
        return articleService.delete(id);
    }

    @RequestMapping(method = RequestMethod.PUT)
    @ResponseBody
    public RS update(@RequestBody Article article) {
        return articleService.update(article);
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public RS get(@PathVariable String id) {
        return articleService.get(id);
    }

    @RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public PageRS list(Article article) {
        return articleService.list(article);
    }

}
